/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.himilco.ocana.gui.supervisor;

import com.himilco.ocana.gui.serviceProvider.ServiceProviderModel;
import com.himilco.ocana.workflow.core.bo.ServiceProviderBO;
import com.himilco.ocana.workflow.core.bo.SupervisorBO;
import com.himilco.ocana.workflow.core.dao.entities.Incident;
import com.himilco.ocana.workflow.core.dao.entities.Ticket;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;

/**
 *
 * @author oussema
 */
@ManagedBean(name = "supc")
@SessionScoped
public class SupervisorController implements Serializable { 

    private SupervisorModel supm = new SupervisorModel();
    @EJB
    private SupervisorBO supBO;
    
    public List<Ticket> getTickets() {
        supm.setTickets(supBO.findAllConfirmedTickets());
        System.out.println("Number of tickets in Controller " + supm.getTickets().size());
        return supm.getTickets();
    }
    

    public void checkConfirmation() {
        System.out.println("save pushed");
        System.out.println("buttom checked status: " + supm.isValue2());
        if (supm.isValue2()) {
            System.out.println("confirmating SP Tikcet");
            getSupBO().updateTicket(getSupm().getSelectedTicket());
        }
    }

    public SupervisorController() {
    }

    public void onRowSelect() {
        System.out.println("Row selected!!");
    }

    public SupervisorModel getSupm() {
        return supm;
    }

    public void setSupm(SupervisorModel supm) {
        this.supm = supm;
    }

    public SupervisorBO getSupBO() {
        return supBO;
    }
}
